#ifndef POPUPMENU_H
#define POPUPMENU_H

#include <QMenu>

class Curve;
class PlotPopupMenu : public QMenu
{
    Q_OBJECT
public:

    enum MenuType
    {
        MT_Clear = 0,

        MT_Range,
        MT_UpdateTime,

        MT_ScopeFollow,
        MT_ScopeCurveUpdate,
        MT_PeriodUpdate,

        MT_Pause,

        MT_Noise,
        MT_Shift,

        MT_Save,
        MT_SaveAsPng,
        MT_Import,

        MT_SavePeriod, // 周期保存

        MT_FFT,
    };

    PlotPopupMenu(QWidget *parent = nullptr);
    ~PlotPopupMenu();

    void setConfig(bool isScopeCurveUpdate, bool isScopeFollow, bool isPeriodUpdate, bool isPause);
    void setGraphCnt(int cnt);
    void setCurve(Curve &curve);
    void setVisibleMenu(QList<bool> visibles);

signals:
    void selected(MenuType type, bool checked = false);
    void fullScreen(int graphIndex);
    void setVisi(int graphIndex, bool visible);

protected:
    void addFullScreenActions();
    void addVisibleActions();

private:
    Curve   *m_curve;

    QMenu   *m_menuFullScreen;
    QMenu   *m_menuVisible;
    QAction *m_actClear;
    QAction *m_actRange;
    QAction *m_actUpdateTime;

    QAction *m_actScopeCurveUpdate;
    QAction *m_actScopeFollow;
    QAction *m_actPeriodUpdate;

    QAction *m_actPause;

    QAction *m_actNoise;
    QAction *m_actShift;

    QAction *m_actSave;
    QAction *m_actSaveAsPng;
    QAction *m_actImport;

    QAction *m_actSavePeriod;

    QAction *m_actFFT;

    int     m_graphCnt = 0;
};

Q_DECLARE_METATYPE(PlotPopupMenu::MenuType);

#endif // POPUPMENU_H
